package com.fengye.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fengye.api.mapper.PicturesMapper;
import com.fengye.api.service.PicturesService;
import com.fengye.common.domain.MyPage;
import com.fengye.common.domain.entity.Pictures;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
* @author sunlei
* @description 针对表【fy_pictures(存储图片模板的表)】的数据库操作Service实现
* @date 2024-05-18 22:32:42
*/
@Transactional(rollbackFor = {Exception.class, Error.class})
@Service
public class PicturesServiceImpl extends ServiceImpl<PicturesMapper, Pictures>
    implements PicturesService {

    @Override
    public MyPage<Pictures> picTplList(Long categoryId, Integer pageNum, Integer pageSize) {

        LambdaQueryWrapper<Pictures> queryWrapper = new LambdaQueryWrapper<>();
        // 如果有分类id
        queryWrapper.eq(Pictures::getCategoryId, categoryId);
        // 分页查询
        Page<Pictures> page = new Page<Pictures>(pageNum, pageSize);
        Page<Pictures> picTplPage = page(page, queryWrapper);

        return new MyPage<Pictures>(picTplPage.getRecords(), picTplPage.getTotal(), picTplPage.getCurrent(), picTplPage.getSize());
    }
}




